/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.ugame.model.dal;

import vn.ugame.model.entity.Comment;
import vn.ugame.model.entity.Account;
import vn.ugame.model.entity.Image;
import vn.ugame.model.entity.Item;
import vn.ugame.model.entity.ItemStatus;
import vn.ugame.model.entity.ImageType;
import vn.ugame.model.entity.Module;
import vn.ugame.model.entity.Category;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 *
 * @author Namtp
 */
public class StoreDA {

    private List<Category> categoryList;
    private List<Item> itemList;
    private List<Image> imageList;
    private List<Account> accountList;
    private List<Comment> commentList;
    private Locale locale;

    public StoreDA(Locale locale) {
        this.locale = locale;
        categoryList = new ArrayList<Category>();
        itemList = new ArrayList<Item>();
        imageList = new ArrayList<Image>();
        accountList = new ArrayList<Account>();
        commentList = new ArrayList<Comment>();
        createCategories();
        createItems();
        createImages();
        createAccounts();
        createComments();
    }

    public Locale getLocale() {
        return locale;
    }

    public List<Item> findItems(String moduleId, String keyword, int page, int pageSize) {
        List<Item> items = new ArrayList<Item>();

        ModuleDA moduleDA = new ModuleDA(locale);
        Module module = moduleDA.findModuleById(moduleId);

        int count = 0;

        if (module != null && module.getType().equals(vn.ugame.module.ModuleType.STORE_ALL)) {
            for (Item item : itemList) {
                if (item.getLocale().getLanguage().equalsIgnoreCase(locale.getLanguage())) {
                    count++;
                    if (count > (page - 1) * pageSize) {
                        items.add(item);

                        if (count >= page * pageSize) {
                            break;
                        }
                    }
                }
            }
        } else if (module != null && module.getType().equals(vn.ugame.module.ModuleType.STORE_SPECIFIC)) {
            for (Item item : itemList) {
                if (item.getLocale().getLanguage().equalsIgnoreCase(locale.getLanguage())) {
                    if (item.getModule().getId().equals(moduleId)) {
                        count++;
                        if (count > (page - 1) * pageSize) {
                            items.add(item);
                            if (count >= page * pageSize) {
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (getLocale().getLanguage().equalsIgnoreCase("en-US")) {
            for (Item item : items) {
                item.setPrice(item.getPrice() / 20000);
            }
        }
        return items;
    }

    public int count(String moduleId, String keyword) {
        ModuleDA moduleDA = new ModuleDA(locale);
        Module module = moduleDA.findModuleById(moduleId);

        if (module != null && module.getType().equals(vn.ugame.module.ModuleType.STORE_ALL)) {
            return itemList.size();
        } else if (module != null && module.getType().equals(vn.ugame.module.ModuleType.STORE_SPECIFIC)) {
            int count = 0;
            for (Item item : itemList) {
                if (item.getModule().getId().equals(moduleId)) {
                    count++;
                }
            }
            return count;
        }
        return 0;
    }

    public Item findItemById(String id) {
        for (Item item : itemList) {
            if (item.getId().equals(id) 
                    && item.getLocale().getLanguage().equalsIgnoreCase(locale.getLanguage())) {
                return item;
            }
        }
        return null;
    }
    
    public Item findItem(String id, String name) {
        for (Item item : itemList) {
            if (item.getId().equals(id) 
                    && item.getName().equals(name)
                    && item.getLocale().getLanguage().equalsIgnoreCase(locale.getLanguage())) {
                return item;
            }
        }
        return null;
    }

    public List<Item> findLocalItems(String id){
        List<Item> items = new ArrayList<Item>();
        for (Item item : itemList) {
            if(item.getId().equals(id)){
                items.add(item);
            }
        }
        return items;
    }
    
    public List<Image> findImages(int imageType, String itemId, int number) {
        List<Image> images = new ArrayList<Image>();
        boolean conditions;
        for (Image image : imageList) {
            conditions = image.getType() == imageType;
            if (itemId != null) {
                conditions &= image.getItem().getId().equals(itemId);
            }
            if (conditions) {
                images.add(image);
            }
        }
        if (number > 0) {
            images = images.subList(0, number);
        }
        return images;
    }

    public List<Comment> findComments(String itemId){
        List<Comment> comments = new ArrayList<Comment>();
        for (Comment comment : commentList) {
            if(comment.getItem().getId().equals(itemId)){
                comments.add(comment);
            }
        }
        return comments;
    }
    
    public Category findCategoryById(String id){
        for (Category category : categoryList) {
            if(category.getId().equals(id)){
                return category;
            }
        }
        return null;
    }
    
    public Category findCategory(String id, Locale locale){
        for (Category category : categoryList) {
            if(category.getId().equals(id) && category.getLocale().getLanguage().equalsIgnoreCase(locale.getLanguage())){
                return category;
            }
        }
        return null;
    }
    
    public Account findAccountById(String id){
        for (Account account : accountList) {
            if(account.getId().equals(id)){
                return account;
            }
        }
        return null;
    }
    
    private void createCategories(){
        Category category = new Category("C001", "arcade-action", "Arcade & Action");
        category.setLocale(new Locale("en-US"));
        categoryList.add(category);
        
        category = new Category("C001", "phieu-luu-hanh-dong", "Phiêu lưu & Hành động");
        category.setLocale(new Locale("vi-VN"));
        categoryList.add(category);
    }
    
    private void createItems() {
        ModuleDA moduleDA = new ModuleDA(locale);
        Item item = new Item("I001", "Great Little War Game", 4, 450,
                "/items/files/be3674021cBive_qplay_1.0.120120628_C1.apk",
                5000, 4154, new java.util.Date(), ItemStatus.HOT,
                4415359, "GLWG is the hit 3D turn-based strategy game that everyone's talking about.",
                1295, "<p>GLWG is the hit 3D turn-based strategy game that everyone's talking about. "
                + "With a unique comical style and plenty of laughs and excitement, "
                + "you'll keep coming back again and again for \"just one more go.\"</p>"
                + "<p>Core Features:<br />❋ Campaign mode<br />❋ Multiplayer mode<br />"
                + "❋ Skirmish mode<br />❋ openFeint achievements<br />❋ Four difficulty settings<br />"
                + "❋ Lush visuals<br />❋ Full 3D terrain affects gameplay<br />"
                + "❋ Simple control method<br />❋ Lots of units<br />❋ Lots of terrain types<br />"
                + "❋ High replayability<br />❋ Tons of humour<br />❋ Absolutely no birds or zombies<br />"
                + "Take command of your army and battle the foe on land, sea and air but be sure to make "
                + "wise decisions as you go. You want to deploy your soldiers to take full advantage "
                + "of the higher terrain, natural choke points, ambush spots and defensive walls. "
                + "Get it right and the bad guys will lose to your superior strategy skills.<br />"
                + "See what other critics are saying:<br />❋ TapScape review: 10/10<br />"
                + "Great Little War Game is just that: a well-designed and enjoyable tactical "
                + "war game perfect for those who enjoy the lighter side of virtual warfare.</p>"
                + "<p>❋ Touch Arcade review: 5/5<br />I'll call Great Little War Game \"great\" "
                + "without hesitation\" ... \"the kind of game you can really sink your teeth "
                + "into, which is rare enough. So I'm delighted to discover that it's also rich "
                + "in features, good looking and full of humor.<br />❋ Top10.com: First place (march)<br />"
                + "The lavish production values of the game, incredible attention "
                + "to detail and excellent animation gives you a sense of aerial, "
                + "naval and land warfare that gets as good as you can expect on a small screen</p>"
                + "<p>Varied missions are the order of the day here - capture the enemy HQ, "
                + "escort the Generalissimo to safety, guide small squads behind enemy lines, "
                + "defend your base...you get the picture. There are 30 missions included, "
                + "so it's going to be one crazy ride if you decide you’re brave enough to give them a try.<br />"
                + "What are you waiting for? Right now, as you sit reading this, there is a battalion "
                + "of soldiers just waiting for your command. Download Great Little War Game now and "
                + "take your place alongside your troops. Lead well, live long and have fun.</p>",
                "great-little-war-game");
        item.setLocale(new Locale("en-US"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);
        
        item = new Item("I001", "Trò Chơi Chiến Tranh", 4, 450,
                "/items/files/be3674021cBive_qplay_1.0.120120628_C1.apk",
                5000, 4154, new java.util.Date(), ItemStatus.HOT,
                4415359, "GLWG là hit 3D lần lượt dựa trên chiến lược trò chơi mà tất cả mọi người đang nói về.",
                1295, "<p>GLWG là hit 3D lần lượt dựa trên chiến lược trò chơi mà tất cả mọi người đang nói về."
                + "Với một phong cách hài hước độc đáo và nhiều tiếng cười và sự phấn khích,"
                + "Bạn sẽ tiếp tục trở lại một lần nữa và một lần nữa cho \" chỉ là một đi. \"</p>"
                + "<p> Tính năng cốt lõi: <br /> ❋ Chiến dịch chế độ <br /> ❋ Multiplayer chế độ <br />"
                + "❋ chế độ skirmish <br /> ❋ thành tựu OpenFeint <br /> ❋ Bốn thiết lập khó khăn <br />"
                + "❋ Lush hình ảnh <br /> ❋ địa hình 3D Full ảnh hưởng đến gameplay <br />"
                + "❋ phương pháp kiểm soát đơn giản <br /> ❋ Rất nhiều đơn vị <br /> ❋ Rất nhiều loại địa hình <br />"
                + "❋ cao chơi lại <br /> ❋ tấn hài hước <br /> ❋ Tuyệt đối không có chim hoặc zombies <br />"
                + "Hãy chỉ huy của quân đội và chiến đấu của kẻ thù trên biển, đất và không khí nhưng chắc chắn sẽ làm"
                + "Quyết định khôn ngoan như bạn đi Bạn muốn triển khai các binh sĩ của bạn để tận dụng"
                + "Của các địa hình cao hơn, điểm tự nhiên sặc, phục kích các điểm và các bức tường phòng thủ."
                + "Cho nó đúng và những kẻ xấu sẽ bị mất các kỹ năng chiến lược cấp trên của bạn. <br />"
                + "Xem những gì các nhà phê bình khác nói: <br /> ❋ TapScape đánh giá: 10/10 <br />"
                + "Great Game chiến Little rằng: một chiến thuật được thiết kế tốt và thú vị"
                + "Chiến tranh trò chơi hoàn hảo cho những người thưởng thức phía bên nhẹ hơn của chiến tranh ảo. </p>"
                + "Xem những gì các nhà phê bình khác nói: <br /> ❋ TapScape đánh giá: 10/10 <br />"
                + "Great Game chiến Little rằng: một chiến thuật được thiết kế tốt và thú vị"
                + "Chiến tranh trò chơi hoàn hảo cho những người thưởng thức phía bên nhẹ hơn của chiến tranh ảo. </p>"
                + "<p> ❋ Touch Arcade đánh giá: 5/5 <br /> Tôi sẽ gọi Little War, Chơi Game \" \""
                + "Không do dự: \" ... \"Các loại trò chơi mà bạn thực sự có thể chìm răng của bạn"
                + "Vào, mà là rất hiếm. Vì vậy, tôi rất vui mừng khám phá ra rằng nó cũng phong phú"
                + "Trong các tính năng, đẹp trai và hài hước <br /> ❋ Top10.com: Đầu tiên diễn ra (tháng ba) <br />"
                + "Việc sản xuất các giá trị xa hoa của trò chơi, sự chú ý đáng kinh ngạc"
                + "Đến từng chi tiết và hình ảnh động tuyệt vời mang đến cho bạn một cảm giác trên không"
                + "Hải quân và chiến tranh đất mà được tốt như bạn có thể mong đợi trên một màn hình nhỏ </p>"
                + "<p> Nhiệm vụ đa dạng là thứ tự của ngày - chụp HQ kẻ thù,"
                + "Hộ tống Tổng tư an toàn, hướng dẫn các đội nhỏ đằng sau các dòng kẻ thù,"
                + "Bảo vệ cơ sở của bạn ... bạn sẽ có được hình ảnh có 30 nhiệm vụ bao gồm,."
                + "Để nó sẽ là một chuyến đi điên nếu bạn quyết định bạn đủ can đảm để cung cấp cho họ một thử. <br />"
                + "Bạn đang chờ gì nữa Ngay bây giờ, khi bạn ngồi đọc sách này, có một tiểu đoàn"
                + "Của những người lính chỉ cần chờ đợi lệnh của bạn Tải về Great Game chiến nhỏ bây giờ.",
                "tro-choi-chien-tranh");
        item.setLocale(new Locale("vi-VN"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I002", "GLWG:All Out War", 3.2, 650,
                "/items/files/d179f3ed7dOlympia_qplay_1.0.0.20120625.c1.apk",
                5000, 1876, new java.util.Date(), ItemStatus.NONE,
                6034812, "All Out War is another exciting episode of the critically acclaimed 3D",
                2567, "<p>All Out War is another exciting episode of the critically acclaimed 3D "
                + "turn-based strategy game \"Great Little War Game\". Retaining the in-depth gameplay, "
                + "humour, comical style and graphical excellence of the original game.<br />"
                + "Please note that this is not a sequel but a stripped down version of the "
                + "original game, designed just to allow play of these two extra campaigns. "
                + "If you don't already own the main game, we recommend you look at that first as "
                + "it contains more general features and a gentler introduction to the gameplay.<br />"
                + "Warning: These levels are fiendishly challenging!<br />Core Features:<br />"
                + "❋ Campaign mode<br />❋ Four difficulty settings<br />❋ Lush visuals<br />"
                + "❋ Full 3D terrain affects gameplay<br />❋ Simple control method<br />"
                + "❋ Lots of units<br />❋ Lots of terrain types<br />❋ High replayability<br />"
                + "❋ Tons of humour<br />Take control of numerous different military units over air, "
                + "sea and land to pulverise the enemy into submission. There are 2 new campaigns "
                + "to test yourself against \"All Out War\" and \"Holiday From Hell\", both of which will "
                + "push you and your men to the limit (and possibly give Generalissimo a nice quiet holiday).</p>"
                + "<p>You have to battle through desert, jungle, temperate and Arctic conditions to keep your "
                + "general safe, which is no mean feat given where he likes to take a holiday...<br />"
                + "So take control of your men, lead them to a glorious victory and then maybe sit down "
                + "and have a cup of tea.</p>", "glwg-all-out-war");
        item.setLocale(new Locale("en-US"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I002", "GLWG:Chiến tranh tổng lực", 3.2, 650,
                "/items/files/d179f3ed7dOlympia_qplay_1.0.0.20120625.c1.apk",
                5000, 1876, new java.util.Date(), ItemStatus.NONE,
                6034812, "Tất cả các chiến Out là một tập phim thú vị của 3D phê bình đánh giá",
                2567, "<p>All Out War is another exciting episode of the critically acclaimed 3D "
                + "turn-based strategy game \"Great Little War Game\". Retaining the in-depth gameplay, "
                + "humour, comical style and graphical excellence of the original game.<br />"
                + "Please note that this is not a sequel but a stripped down version of the "
                + "original game, designed just to allow play of these two extra campaigns. "
                + "If you don't already own the main game, we recommend you look at that first as "
                + "it contains more general features and a gentler introduction to the gameplay.<br />"
                + "Warning: These levels are fiendishly challenging!<br />Core Features:<br />"
                + "❋ Campaign mode<br />❋ Four difficulty settings<br />❋ Lush visuals<br />"
                + "❋ Full 3D terrain affects gameplay<br />❋ Simple control method<br />"
                + "❋ Lots of units<br />❋ Lots of terrain types<br />❋ High replayability<br />"
                + "❋ Tons of humour<br />Take control of numerous different military units over air, "
                + "sea and land to pulverise the enemy into submission. There are 2 new campaigns "
                + "to test yourself against \"All Out War\" and \"Holiday From Hell\", both of which will "
                + "push you and your men to the limit (and possibly give Generalissimo a nice quiet holiday).</p>"
                + "<p>You have to battle through desert, jungle, temperate and Arctic conditions to keep your "
                + "general safe, which is no mean feat given where he likes to take a holiday...<br />"
                + "So take control of your men, lead them to a glorious victory and then maybe sit down "
                + "and have a cup of tea.</p>", "glwg-chien-tranh-tong-luc");
        item.setLocale(new Locale("vi-VN"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I003", "Swords and Soldiers", 2.4, 198,
                "/items/files/2e4879ea9dChup-Anh-Voi-Nguoi-Noi-Tieng.apk",
                10000, 5362, new java.util.Date(), ItemStatus.NEW,
                1000000, "The funniest action-strategy game you’ll ever play!",
                3398, "<p>The funniest action-strategy game you’ll ever play!<br />"
                + "Swipe, poke and tap to command an army of Vikings in their quest "
                + "to create the ultimate BBQ sauce, lead the Aztecs in defense of the "
                + "Holy Pepper and build an array of explosive Chinese toys! Build your "
                + "own forces and defeat your foes using berserkers, dart blowers, giant "
                + "boulders, ninja monkeys (yes, we really mean it – ninja monkeys!) and many more!<br />"
                + "Swords and Soldiers Highlights<br />• Hilarious characters and storyline mean "
                + "you'll be playing with one huge grin.<br />"
                + "• Command hordes of Vikings, Aztecs and Chinese warriors, each with their own unique skills.<br />"
                + "• Three epic campaigns with unique challenges to keep you entertained for hours.<br />"
                + "• Fully customizable Skirmish mode means endless replayability.<br />"
                + "• Hours of gameplay with achievements, challenges and leaderboards.</p>",
                "swords-and-soldiers");
        item.setLocale(new Locale("en-US"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I003", "Thank kiếm và Chiến binh", 2.4, 198,
                "/items/files/2e4879ea9dChup-Anh-Voi-Nguoi-Noi-Tieng.apk",
                10000, 5362, new java.util.Date(), ItemStatus.NEW,
                1000000, "Các chiến lược hành động hài hước trò chơi, bạn sẽ bao giờ chơi!",
                3398, "<p>The funniest action-strategy game you’ll ever play!<br />"
                + "Swipe, poke and tap to command an army of Vikings in their quest "
                + "to create the ultimate BBQ sauce, lead the Aztecs in defense of the "
                + "Holy Pepper and build an array of explosive Chinese toys! Build your "
                + "own forces and defeat your foes using berserkers, dart blowers, giant "
                + "boulders, ninja monkeys (yes, we really mean it – ninja monkeys!) and many more!<br />"
                + "Swords and Soldiers Highlights<br />• Hilarious characters and storyline mean "
                + "you'll be playing with one huge grin.<br />"
                + "• Command hordes of Vikings, Aztecs and Chinese warriors, each with their own unique skills.<br />"
                + "• Three epic campaigns with unique challenges to keep you entertained for hours.<br />"
                + "• Fully customizable Skirmish mode means endless replayability.<br />"
                + "• Hours of gameplay with achievements, challenges and leaderboards.</p>",
                "thank-kiem-va-chien-binh");
        item.setLocale(new Locale("vi-VN"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I005", "The Oregon Trail: Settler", 5, 1290,
                "/items/files/5e94d6af29Euro2012_1.0.3_qplay_20120609_c03.apk",
                15000, 9821, new java.util.Date(), ItemStatus.NEW,
                1859, "Saddle-up for an all-new Oregon adventure!",
                2046272, "<p>Saddle-up for an all-new Oregon adventure!<br />"
                + "Experience a brand new adventure in The Oregon Trail: American Settler!<br />"
                + "You’ve conquered the journey, now tame the frontier in this free game that continues "
                + "The OregonTrail story as your pioneer family finally settles down to start a new home.<br />"
                + "ALL YOU LOVED AND MORE<br />A new adventure gathering features you loved from the "
                + "original “The Oregon Trail” plus great new ones from this brand new game!<br />"
                + "A VILLAGE LIKE NO OTHER<br />Create your own personalized frontier town by "
                + "adding buildings, animals, crops and taking care of your people’s happiness. "
                + "Earn gold and buy all kinds of items to really make it unique.<br />"
                + "HISTORIC ENCOUNTERS<br />Meet up with some of the most important figures "
                + "in history and have a quick and educational chat, or talk to your townsfolk "
                + "to uncover quests and some fascinating historical facts.<br />"
                + "SURPRISES ABOUND<br />The West truly is a wild and dangerous place, and you "
                + "never know whether a stampede of buffalo, a hurricane or bandit attacks may "
                + "strike! Use strategy to make the best choice and protect your village from anything!<br />"
                + "MINI-GAMES, BIG FUN<br />Play the fun Hunting or Fishing mini-games to gather resources"
                + " for your people and stockpile enough supplies to get you through even the toughest of times.<br />"
                + "SHARE THE ADVENTURE<br />Make new friends or meet-up with old ones by taking a "
                + "trip to your neighboring villages. Exchange gifts to deepen the bonds of friendship "
                + "and help each other make the most amazing villages possible.<br />"
                + "For fans of simulation, farming and tycoon games.<br />Let’s Play! by Gameloft</p>",
                "the-oregon-trail-settler");
        item.setLocale(new Locale("en-US"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);
        
        item = new Item("I005", "The Oregon Trail: Định Cư", 5, 1290,
                "/items/files/5e94d6af29Euro2012_1.0.3_qplay_20120609_c03.apk",
                15000, 9821, new java.util.Date(), ItemStatus.NEW,
                1859, "Saddle-up cho một cuộc phiêu lưu mới Oregon tất cả!",
                2046272, "<p>Saddle-up for an all-new Oregon adventure!<br />"
                + "Experience a brand new adventure in The Oregon Trail: American Settler!<br />"
                + "You’ve conquered the journey, now tame the frontier in this free game that continues "
                + "The OregonTrail story as your pioneer family finally settles down to start a new home.<br />"
                + "ALL YOU LOVED AND MORE<br />A new adventure gathering features you loved from the "
                + "original “The Oregon Trail” plus great new ones from this brand new game!<br />"
                + "A VILLAGE LIKE NO OTHER<br />Create your own personalized frontier town by "
                + "adding buildings, animals, crops and taking care of your people’s happiness. "
                + "Earn gold and buy all kinds of items to really make it unique.<br />"
                + "HISTORIC ENCOUNTERS<br />Meet up with some of the most important figures "
                + "in history and have a quick and educational chat, or talk to your townsfolk "
                + "to uncover quests and some fascinating historical facts.<br />"
                + "SURPRISES ABOUND<br />The West truly is a wild and dangerous place, and you "
                + "never know whether a stampede of buffalo, a hurricane or bandit attacks may "
                + "strike! Use strategy to make the best choice and protect your village from anything!<br />"
                + "MINI-GAMES, BIG FUN<br />Play the fun Hunting or Fishing mini-games to gather resources"
                + " for your people and stockpile enough supplies to get you through even the toughest of times.<br />"
                + "SHARE THE ADVENTURE<br />Make new friends or meet-up with old ones by taking a "
                + "trip to your neighboring villages. Exchange gifts to deepen the bonds of friendship "
                + "and help each other make the most amazing villages possible.<br />"
                + "For fans of simulation, farming and tycoon games.<br />Let’s Play! by Gameloft</p>",
                "the-oregon-trail-dinh-cu");
        item.setLocale(new Locale("vi-VN"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I004", "SAMURAI vs ZOMBIES DEFENSE", 4, 392,
                "/items/files/97b188d3dcCuoc-Chien-Hoa-Qua.apk",
                15000, 8762, new java.util.Date(), ItemStatus.HOT,
                3181237, "Play as a Samurai and defend your village against hordes of attacking zombies!",
                4512, "<p>Play as a Samurai and defend your village against hordes of attacking zombies!<br />"
                + "Play as the heroic Samurai and defend your village against hordes of attacking zombies! "
                + "Recruit allies and build defenses to stop them!<br />STRATEGIC GAMEPLAY: set up your "
                + "defenses against hordes of zombies!<br />WORK WITH ALLIES: get some help in the store with "
                + "farmers, warriors, archers and much more!<br />WIN BIG IN MINI GAMES: play Pachinko to "
                + "earn rare items!<br />UPGRADE YOUR SAMURAI: Become more powerful by acquiring better "
                + "weapons, defenses and magical abilities!<br />Use of this application is governed "
                + "by Glu Mobile’s Terms of Use. Collection and use of personal data are subject to "
                + "Glu Mobile’s Privacy Policy. Both policies are available at www.glu.com. Additional "
                + "terms may also apply.<br />SAMURAI vs ZOMBIES DEFENSE is free to play, but you can "
                + "choose to pay real money for some extra items.</p>",
                "samurai-vs-zombies-defense");
        item.setLocale(new Locale("en-US"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

        item = new Item("I004", "SAMURAI vs THÂY MA", 4, 392,
                "/items/files/97b188d3dcCuoc-Chien-Hoa-Qua.apk",
                15000, 8762, new java.util.Date(), ItemStatus.HOT,
                3181237, "Nghe như là Samurai và bảo vệ ngôi làng của bạn chống lại bầy lũ tấn công zombie!",
                4512, "<p>Play as a Samurai and defend your village against hordes of attacking zombies!<br />"
                + "Play as the heroic Samurai and defend your village against hordes of attacking zombies! "
                + "Recruit allies and build defenses to stop them!<br />STRATEGIC GAMEPLAY: set up your "
                + "defenses against hordes of zombies!<br />WORK WITH ALLIES: get some help in the store with "
                + "farmers, warriors, archers and much more!<br />WIN BIG IN MINI GAMES: play Pachinko to "
                + "earn rare items!<br />UPGRADE YOUR SAMURAI: Become more powerful by acquiring better "
                + "weapons, defenses and magical abilities!<br />Use of this application is governed "
                + "by Glu Mobile’s Terms of Use. Collection and use of personal data are subject to "
                + "Glu Mobile’s Privacy Policy. Both policies are available at www.glu.com. Additional "
                + "terms may also apply.<br />SAMURAI vs ZOMBIES DEFENSE is free to play, but you can "
                + "choose to pay real money for some extra items.</p>",
                "samurai-vs-thay-ma");
        item.setLocale(new Locale("vi-VN"));
        item.setModule(moduleDA.findLocalModule("M4", item.getLocale()));
        item.setCategory(findCategory("C001", item.getLocale()));
        itemList.add(item);

//            item = new Item("G006", "M4", "Xếp Bóng (Line 2012)", "/items/icons/9.png", 1.6, 584,
//                    "/items/files/67847a40d3line_1.0.0_qplay_20120606_c2.apk",
//                    5000, 3948, new java.util.Date(), ItemStatus.NONE);
//            itemList.add(item);
//
//            item = new Item("G007", "M6", "Phong thủy - Bói", "/items/icons/12.png", 4.5, 123,
//                    "/items/files/c1b6c38d1eThayPhan_2.0.5_qplay_20120607_c11.apk",
//                    15000, 1657, new java.util.Date(), ItemStatus.HOT);
//            itemList.add(item);
//
//            item = new Item("G008", "M6", "Chat yahoo yoyo", "/items/icons/11.png", 2.6, 374,
//                    "/items/files/YoYo_1.0.9.301_s.qplay.vn_20111017.apk",
//                    10000, 3897, new java.util.Date(), ItemStatus.NONE);
//            itemList.add(item);        
    }

    private void createImages() {
        //Item 1
        Item item = findItemById("I001");
        
        Image image = new Image(1, "/items/icons/1.png", ImageType.ICON_64);
        image.setItem(item);
        imageList.add(image);

        image = new Image(2, "/items/icons/1.png", ImageType.ICON_124);
        image.setItem(item);
        imageList.add(image);

        image = new Image(3, "/items/banners/1-small.jpg", ImageType.BANNER_180_120);
        image.setItem(item);
        imageList.add(image);

        image = new Image(4, "/items/banners/1-large.jpg", ImageType.BANNER_480_180);
        image.setItem(item);
        imageList.add(image);

        image = new Image(5, "/items/screens/1-1.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(6, "/items/screens/1-2.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(7, "/items/screens/1-3.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(8, "/items/screens/1-4.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        //Item 2
        item = findItemById("I002");
        
        image = new Image(9, "/items/icons/2.png", ImageType.ICON_64);
        image.setItem(item);
        imageList.add(image);

        image = new Image(10, "/items/icons/2.png", ImageType.ICON_124);
        image.setItem(item);
        imageList.add(image);

        image = new Image(11, "/items/banners/2-small.jpg", ImageType.BANNER_180_120);
        image.setItem(item);
        imageList.add(image);

        image = new Image(12, "/items/banners/2-large.jpg", ImageType.BANNER_480_180);
        image.setItem(item);
        imageList.add(image);

        image = new Image(13, "/items/screens/2-1.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(14, "/items/screens/2-2.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(15, "/items/screens/2-3.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(16, "/items/screens/2-4.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(17, "/items/screens/2-5.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(18, "/items/screens/2-6.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        //Item 3
        item = findItemById("I003");
        
        image = new Image(19, "/items/icons/3.png", ImageType.ICON_64);
        image.setItem(item);
        imageList.add(image);

        image = new Image(20, "/items/icons/3.png", ImageType.ICON_124);
        image.setItem(item);
        imageList.add(image);

        image = new Image(21, "/items/banners/3-small.jpg", ImageType.BANNER_180_120);
        image.setItem(item);
        imageList.add(image);

        image = new Image(22, "/items/banners/3-large.jpg", ImageType.BANNER_480_180);
        image.setItem(item);
        imageList.add(image);

        image = new Image(23, "/items/screens/3-1.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(24, "/items/screens/3-2.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(25, "/items/screens/3-4.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(26, "/items/screens/3-5.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        //Item 4
        item = findItemById("I004");
        
        image = new Image(27, "/items/icons/4.png", ImageType.ICON_64);
        image.setItem(item);
        imageList.add(image);

        image = new Image(28, "/items/icons/4.png", ImageType.ICON_124);
        image.setItem(item);
        imageList.add(image);

        image = new Image(29, "/items/banners/4-small.jpg", ImageType.BANNER_180_120);
        image.setItem(item);
        imageList.add(image);

        image = new Image(30, "/items/banners/4-large.jpg", ImageType.BANNER_480_180);
        image.setItem(item);
        imageList.add(image);

        image = new Image(31, "/items/screens/4-1.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(32, "/items/screens/4-2.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(33, "/items/screens/4-3.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(34, "/items/screens/4-4.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(35, "/items/screens/4-5.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(36, "/items/screens/4-6.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(37, "/items/screens/4-7.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(38, "/items/screens/4-8.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        //Item 5
        item = findItemById("I005");
        
        image = new Image(39, "/items/icons/5.png", ImageType.ICON_64);
        image.setItem(item);
        imageList.add(image);

        image = new Image(40, "/items/icons/5.png", ImageType.ICON_124);
        image.setItem(item);
        imageList.add(image);

        image = new Image(41, "/items/banners/5-small.jpg", ImageType.BANNER_180_120);
        image.setItem(item);
        imageList.add(image);

        image = new Image(42, "/items/banners/5-large.jpg", ImageType.BANNER_480_180);
        image.setItem(item);
        imageList.add(image);

        image = new Image(43, "/items/screens/5-1.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(44, "/items/screens/5-2.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(45, "/items/screens/5-3.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(46, "/items/screens/5-4.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(47, "/items/screens/5-5.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);

        image = new Image(48, "/items/screens/5-6.jpg", ImageType.SCREEN_SHOT);
        image.setItem(item);
        imageList.add(image);
    }

    private void createAccounts(){
        Account account = new Account("A001", "ugame@gmail.com", "Do Hoang");
        accountList.add(account);
        
        account = new Account("A002", "ugame@gmail.com", "Nam Tran");
        accountList.add(account);
        
        account = new Account("A003", "ugame@gmail.com", "Phong 33b");
        accountList.add(account);
        
        account = new Account("A004", "ugame@gmail.com", "Trung Designer");
        accountList.add(account);
        
        account = new Account("A005", "ugame@gmail.com", "Dũng BK");
        accountList.add(account);
    }
    
    private void createComments() {
        Item item = findItemById("I001");
        Account account = findAccountById("A001");
        
        Comment comment = new Comment("CMT01", new java.util.Date(), "Game chơi rất hay !");
        comment.setAccount(account);
        comment.setItem(item);
        commentList.add(comment);

        account = findAccountById("A002");
        comment = new Comment("CMT02", new java.util.Date(), "Install thế nào vậy các bạn ?");
        comment.setAccount(account);
        comment.setItem(item);
        commentList.add(comment);

        account = findAccountById("A003");
        comment = new Comment("CMT03", new java.util.Date(), "Cứ download về rồi cài bình thường nhé ;)");
        comment.setAccount(account);
        comment.setItem(item);
        commentList.add(comment);

        item = findItemById("I002");
        
        account = findAccountById("A004");
        comment = new Comment("CMT04", new java.util.Date(), "Phiên bản mở rộng này hay wá :D");
        comment.setAccount(account);
        comment.setItem(item);
        commentList.add(comment);

        account = findAccountById("A005");
        comment = new Comment("CMT05", new java.util.Date(), "Game hot của năm là đây =))");
        comment.setAccount(account);
        comment.setItem(item);
        commentList.add(comment);
    }
}
